package main;

import view.list.detailview.DetailViewPresenter;

import javax.swing.*;
import java.awt.*;


@SuppressWarnings("unchecked")
public class MainPanel extends JPanel {
    private BorderLayout borderLayout1 = new BorderLayout();

    //  private ButtonsPanel btPanel=new ButtonsPanel();
    private JSplitPane split = new JSplitPane();
    //  private Preferences prefs=Options.getPreferences();
    private DetailViewPresenter leftPanel = null;
//  private JFMView rightPanel=null;

    public MainPanel() {
        try {
            jbInit();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    void jbInit() throws Exception {
        removeSplitKeyBindings();
        this.setLayout(borderLayout1);

//    this.add(btPanel,BorderLayout.SOUTH);
        this.add(split, BorderLayout.CENTER);

        leftPanel = new DetailViewPresenter();
//    rightPanel=createRightView();

        leftPanel.requestFocus();
        split.add(leftPanel, JSplitPane.LEFT);
//    split.add(rightPanel, JSplitPane.RIGHT);
        split.setDividerLocation(350);
        setButtonsPanel();

    }


    private void removeSplitKeyBindings() {
        ActionMap newSplitActionMap = new ActionMap();
        split.setActionMap(newSplitActionMap);
    }

    private void setButtonsPanel() {
//    Vector buttons=new Vector();

//    JButton f1Button=new JButton("Help (F1)");
//    HelpAction help=new HelpAction();
//    f1Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F1"),"helpButton");
//    f1Button.getActionMap().put("helpButton",help);
//    f1Button.addActionListener(help);

//    JButton f2Button=new JButton("Menu (F2)");
//    PanelMenuAction menu=new PanelMenuAction();
//    f2Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F2"),"menuButton");
//    f2Button.getActionMap().put("menuButton",menu);
//    f2Button.addActionListener(menu);

//    JButton f3Button=new JButton("View (F3)");
//    ViewFileAction view=new ViewFileAction();
//    f3Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F3"),"viewButton");
//    f3Button.getActionMap().put("viewButton",view);
//    f3Button.addActionListener(view);
//
//    JButton f4Button=new JButton("Edit (F4)");
//    EditFileAction edit=new EditFileAction();
//    f4Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F4"),"editButton");
//    f4Button.getActionMap().put("editButton",edit);
//    f4Button.addActionListener(edit);
//
//    JButton f5Button=new JButton("Copy (F5)");
//    CopyAction copy=new CopyAction();
//    f5Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F5"),"copyButton");
//    f5Button.getActionMap().put("copyButton",copy);
//    f5Button.addActionListener(copy);
//
//    JButton f6Button=new JButton("Move (F6)");
//    MoveAction move=new MoveAction();
//    f6Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F6"),"moveButton");
//    f6Button.getActionMap().put("moveButton",move);
//    f6Button.addActionListener(move);
//
//    JButton f7Button=new JButton("Mkdir (F7)");
//    MkdirAction mkdir=new MkdirAction();
//    f7Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F7"),"mkdirButton");
//    f7Button.getActionMap().put("mkdirButton",mkdir);
//    f7Button.addActionListener(mkdir);
//
//    JButton f8Button=new JButton("Delete (F8)");
//    DeleteAction del=new DeleteAction();
//    f8Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F8"),"delButton");
//    f8Button.getActionMap().put("delButton",del);
//    f8Button.addActionListener(del);
//
//    JButton f10Button=new JButton("Quit");
//    QuitAction quit=new QuitAction();
//    f10Button.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F10"),"quitButton");
//    f10Button.getActionMap().put("quitButton",quit);
//    f10Button.addActionListener(quit);

//    buttons.addElement(f1Button);
////    buttons.addElement(f2Button);
//    buttons.addElement(f3Button);
//    buttons.addElement(f4Button);
//    buttons.addElement(f5Button);
//    buttons.addElement(f6Button);
//    buttons.addElement(f7Button);
//    buttons.addElement(f8Button);
//    buttons.addElement(f10Button);
//
//    btPanel.setButtons(buttons);
    }
}